import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    // 暴力枚举
    public static void main2(String[] args) {
        // 处理输入
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int q = in.nextInt();
        int[][] array = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = in.nextInt();
            }
        }
        int[][] query = new int[q][4];
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < 4; j++) {
                query[i][j] = in.nextInt();
            }
        }
        // 处理查询
        for (int i = 0; i < q; i++) {
            // 定位
            int a1 = query[i][0];
            int b1 = query[i][1];
            int a2 = query[i][2];
            int b2 = query[i][3];
            long sum = 0; // 注意数据范围
            for (int j = a1-1; j < a2; j++) {
                for (int k = b1-1; k < b2; k++) {
                    sum += array[j][k];
                }
            }
            System.out.println(sum);
        }
    }


    // 前缀和优化：笨方法
    public static void main1(String[] args) {
        // 处理输入
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int q = in.nextInt();
        int[][] array = new int[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                array[i][j] = in.nextInt();
            }
        }
        int[][] query = new int[q][4];
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < 4; j++) {
                query[i][j] = in.nextInt();
            }
        }
        // 创建辅助数组
        long[][] virtual_array = new long[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                // 只计算一维数组的和
                virtual_array[i][j] = virtual_array[i][j-1] + array[i][j];
            }
        }
        // 处理查询
        for (int i = 0; i < q; i++) {
            // 定位
            int a1 = query[i][0];
            int b1 = query[i][1];
            int a2 = query[i][2];
            int b2 = query[i][3];
            long sum = 0; // 注意数据范围
            for (int j = a1; j <= a2; j++) {
                // （一维数组）列的和，只需要加上最后一列即可
                sum += (virtual_array[j][b2] - virtual_array[j][b1-1]);
            }
            System.out.println(sum);
        }
    }

    // 前缀和优化：找规律
    public static void main(String[] args) {
        // 处理输入
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int q = in.nextInt();
        int[][] array = new int[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                array[i][j] = in.nextInt();
            }
        }
        int[][] query = new int[q][4];
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < 4; j++) {
                query[i][j] = in.nextInt();
            }
        }
        // 创建辅助数组
        long[][] virtual_array = new long[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                virtual_array[i][j] = virtual_array[i][j-1] + virtual_array[i-1][j] + array[i][j] - virtual_array[i-1][j-1];
            }
        }
        // 处理查询
        for (int i = 0; i < q; i++) {
            // 定位
            int a1 = query[i][0];
            int b1 = query[i][1];
            int a2 = query[i][2];
            int b2 = query[i][3];
            long sum = 0; // 注意数据范围
            sum = virtual_array[a2][b2] - virtual_array[a1-1][b2] - virtual_array[a2][b1-1] + virtual_array[a1-1][b1-1];
            System.out.println(sum);
        }
    }
}